<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 500px;
            height: 200px;
            /* border: 1px solid red; */
            background-color: khaki;
            overflow: auto;
        }
        .box table{
            width: 100%;
            /* 合并单元格边框线 */
            border-collapse: collapse;
        }
        .box table tr th,
        .box table tr td{
            border: 1px solid #333;
        }
        .box table tr th{
            height: 50px;
            background-color: skyblue;
        }
        .box table tr td{
            height: 40px;
            text-align: center;
        }
        /* 去掉最后一行单元格的下边框线 */
        .box table tr:last-child td{
            border-bottom-color: transparent;
        }
        /* 去掉第一行单元格的上边框线 */
        .box table tr:first-child th{
            border-top-color: skyblue;
        }

        .box table tr:first-child{
            position: sticky;
            top: 0;
        }

        .box::after{
            content: "";
            display: block;
            height: 1px;
            background-color: #333;
            position: sticky;
            bottom: 0px;
        }
        .box::before{
            content: "";
            display: block;
            height: 1px;
            background-color: #333;
            position: sticky;
            top: 0px;
        }

    </style>
</head>
<body>
    <div class="box">
        <table>
            <tr>
                <th>姓名</th>
                <th>学号</th>
            </tr>
            <tr>
                <td>张一</td>
                <td>0001</td>
            </tr>
            <tr>
                <td>张二</td>
                <td>0002</td>
            </tr>
            <tr>
                <td>张三</td>
                <td>0003</td>
            </tr>
            <tr>
                <td>张四</td>
                <td>0004</td>
            </tr>
            <tr>
                <td>张五</td>
                <td>0005</td>
            </tr>
            <tr>
                <td>张六</td>
                <td>0006</td>
            </tr>
            <tr>
                <td>张七</td>
                <td>0007</td>
            </tr>
            <tr>
                <td>张八</td>
                <td>0008</td>
            </tr>
            <tr>
                <td>张九</td>
                <td>0009</td>
            </tr>
            <tr>
                <td>张十</td>
                <td>0010</td>
            </tr>
        </table>
    </div>
</body>
</html>